package routers

import (
	"github.com/gin-gonic/gin"
	"hc_server/pkg/export"
	"hc_server/pkg/file"
	"hc_server/routers/api"
	v1 "hc_server/routers/api/v1/agentV1"
	"net/http"
)

// InitRouter initialize routing information
func InitRouter() *gin.Engine {
	r := gin.New()
	r.Use(gin.Logger())
	r.Use(gin.Recovery())

	r.StaticFS("/export", http.Dir(export.GetExcelFullPath()))
	r.Static("/file", file.GetRootFileFullPath())
	//r.StaticFS("/qrcode", http.Dir(qrcode.GetQrCodeFullPath()))

	//r.POST("/auth", api.GetAuth)
	r.POST("/upload", api.UploadImage)
	//r.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler))
	apiV1 := r.Group("/api/v1")
	apiV1.POST("/user/login", v1.UserLogin) //用户登录
	apiV1.POST("/user/add", v1.UserAdd)     //用户注册

	//docs.SwaggerInfo.Title = "商户端接口文档"
	//docs.SwaggerInfo.Description = "商户端"
	//docs.SwaggerInfo.Version = "1.0"
	//docs.SwaggerInfo.Host = "192.168.2.88:8080"
	//docs.SwaggerInfo.BasePath = "/api/v1"
	//docs.SwaggerInfo.Schemes = []string{"http", "https"}

	////用户端
	//UserRouter(apiV1.Group("/user"))
	//app代理商v1
	appAgentApiRouterV1 := r.Group("/api/v1/appAgent") //app代理商
	AgentRouter(appAgentApiRouterV1)
	appMerchantApiRouterV1 := r.Group("/api/v1/appMerchant") //app代理商
	MerchantRouter(appMerchantApiRouterV1)
	transactionApiRouterV1 := r.Group("/api/v1/transaction") //用户支付交易
	TransactionRouter(transactionApiRouterV1)

	r.Run(":8080")
	return r
}
